home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group97a.txt
/
000072_icon-group-sender _Wed Mar 5 21:02:39 1997.msg
< prev
next >
Wrap
Internet Message Format
|
2000-09-20
|
2KB
Received: by cheltenham.cs.arizona.edu; Thu, 6 Mar 1997 09:23:14 MST
Date: Wed, 5 Mar 1997 21:02:39 -0600
Message-Id: <199703060302.VAA29037@ns1.cmpu.net>
Mime-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
From: gep2@computek.net
Subject: Recursive directory traversal in Icon
To: icon-group@cs.arizona.edu
X-Mailer: SPRY Mail Version: 04.00.06.17
Errors-To: icon-group-errors@cs.arizona.edu
Status: RO
Content-Length: 1979
>I've been reading the Icon web references, trying to decide if I
should forsake Perl in favor of Icon, and I have two questions.
>(1) How do I traverse a hierarchical directory structure in Icon? I found
chdir, but I didn't find the equivalent of 'ls' and 'stat'. Is there
a way to do this in Icon, or do you rely on the external environment?
In SNOBOL4+, what I did was to write a loadable function DIRFNC() which allows
you to get all the directory information for a given file (or other directory
entry, and accepting wildcards). It also permits you to get volume labels and
subdirectory names in the same way... once you have that, it's fairly simple to
write a recursive tree traversing routine.
The alternative (and which honestly I use a significant fraction of the time,
even having the loadable function I wrote) is to simply execute the external
MS-DOS DIR command (which now permits getting all the directory recursions with
the /S option) and either route the output into a temporary file, or pipe it
directly into the S-BOL program. Regenerating all the complete filenames with
paths is a pretty trivial pattern match from that point.
I think the reason why this kind of thing hasn't been incorporated into the
language itself is because by its nature it's quite operating system dependent,
whereas both Icon and S-BOL are designed to be as independent of the underlying
operating system as possible.
>(2) Why no module system? I've found modules helpful in every language I've
worked with, and Icon doesn't seem to be different in that it could use
such a system. I noticed someone else mention this, but it is not in
the FAQ. Perl has benefitted greatly from the inclusion of modules.
The inclusion feature in SNOBOL4+ makes it quite simple to load subroutines as
needed from one or more library subdirectories, and automatically suppresses
duplicate requests.
Gordon Peterson
http://www.computek.net/public/gep2/